<?php
//error_reporting(E_ALL ^ E_NOTICE);
header('Content-Type:application/json');
if ($_GET['cookie']!=""&&$_GET['type']!="") {
    $COOKIE=$_GET['cookie'];
    $qt=$_GET['type'];
// $time=time();
$DATA="http://dxx.hngqt.org.cn/project/list?time=1664275548747";
$api="http://dxx.hngqt.org.cn/study/studyAdd?time=1664275548747";
$header="Host: dxx.hngqt.org.cn
Connection: keep-alive
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://dxx.hngqt.org.cn
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x6307062c)
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cookie: $COOKIE
Referer: http://dxx.hngqt.org.cn/project/index
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Accept-Encoding: gzip, deflate
Content-Length: 18";

/**

 * 发送post请求

 * @param string $url 请求地址

 * @param array $post_data post键值对数据

 * @return string

 */

function send_post($url, $post_data,$header) {
  $postdata = http_build_query($post_data);

  $options = array(

    'http' => array(

      'method' => 'POST',

      'header' => $header,

      'content' => $postdata,

      'timeout' => 15 * 60 // 超时时间（单位:s）

    )

  );

  $context = stream_context_create($options);

  $result = file_get_contents($url, false, $context);
  return $result;

}

//使用方法


if ($qt=="data") {
    $post_data = array(
  'page'=>1,
  'pageSize'=>10,
);
$DATA=send_post($DATA,$post_data,$header);
echo($DATA);
}else {
    $post_data = array(
  'page'=>1,
  'pageSize'=>10,
);
// $DATA=send_post($DATA,$post_data,$header);
// $arr=json_decode($DATA,true);
// $id=$arr['data']['list'][0]['project_id'];
    if ($qt!=null&&$qt!="") {
    $post_data=array(
        'projectId'=>$qt
        );
        $header1="Host: dxx.hngqt.org.cn
Connection: keep-alive
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://dxx.hngqt.org.cn
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x6307062c)
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cookie: $COOKIE
Referer: http://dxx.hngqt.org.cn/project/index
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Accept-Encoding: gzip, deflate
Content-Length: 13";
        $DATA=send_post($api,$post_data,$header1);
        echo($DATA);
}else {
    echo("没有获取到最新id");
}
}

// echo($id);

}else {
    echo("cookie不能为空！如果为空无法给您账号自动学习! 葫芦侠秦天1013138336");
}
